package com.itheima.day01;

public class Demo02 {
    public static void main(String[] args) {
        Object objA=new Object();
        Object objB=new Object();
        new Thread(()->{
            while (true){
                synchronized (objA){
                    synchronized (objB) {
                        System.out.println("线程1");
                    }
                }
            }
        }).start();
        new Thread(()->{
            while (true){
                synchronized (objB){
                    synchronized (objA) {
                        System.out.println("线程2");
                    }
                }
            }
        }).start();
    }
}
